height =[1,8,6,2,5,4,8,3,7]

var maxArea = function(height) {
       let left=0
       let right=height.length-1
       let area=0
       while(left<right)
       {
          const h=Math.min(height[left],height[right])
          const w=right-left
          area=Math.max(area,h*w)
          if(height[left]<height[right])
          {
            left++
          }
          else{
            right--
          }
       }
       return area

};

console.log(maxArea(height));
